/*----------------------------------------------------------------------------*/
/* Copyright (c) FIRST 2008. All Rights Reserved.                             */
/* Open Source Software - may be modified and shared by FRC teams. The code   */
/* must be accompanied by the FIRST BSD license file in the root directory of */
/* the project.                                                               */
/*----------------------------------------------------------------------------*/
package com.nurdrobotics;

import edu.wpi.first.wpilibj.DriverStation;

/**
 * 
 */
public class DSControls {
    // The following variables give names to each of the analog slider
    // channels on the DriverStation

    public static final int SLIDER_AUTONOMOUS_MAX_TIME = 1;
    public static final int SLIDER_AUTONOMOUS_MAX_SPEED = 2;
    public static final int SLIDER_AUTO_SHOOT_DELAY = 3;
    public static final int SLIDER_STAGER_TIMER_PERCENT = 4;
    // The following variables give names to each of the digital switches
    // on the DriverStation
    public static final int BUTTON_DRIVETRAIN_ENABLE = 1;
    public static final int BUTTON_LIFTER_ENABLE = 2;
    public static final int BUTTON_STAGER_ENABLE = 3;
    public static final int BUTTON_AUTO_SHOOT_ENABLE = 4;
    public static final int BUTTON_WEDGE_ENABLE = 5;
    private static DriverStation m_ds = null;

    /*
     * Return the value of the specified analog slider on the DriverStation
     * The value will be returned in the range of 0 to 1
     */
    public static double getSlider(int channel) {
        if (m_ds == null) {
            m_ds = DriverStation.getInstance();
        }
        if (m_ds == null) {
            Dashboard.setErrorStatus("DSERROR");
            return 0;

        }

        // Analog sliders read 0 to 5
        // By dividing the returned value by 5.0 we get values in the
        // range of 0 to 1 inclusive
        return (m_ds.getAnalogIn(channel) / 5.0);
    }

    public static boolean getButton(int channel) {
        if (m_ds == null) {
            m_ds = DriverStation.getInstance();
        }
        if (m_ds == null) {
            Dashboard.setErrorStatus("DSERROR");
            return false;

        }

        return (m_ds.getDigitalIn(channel));
    }
}
